<?php

class Cache {

    function get($file_name) {
        $file_name = ROOT . DS . 'tmp' . DS . 'cache' . DS . $file_name;
        if (file_exists($file_name)) {
            $handle = fopen($file_name, 'rb');
            $variable = fread($handle, filesize($file_name));
            fclose($handle);
            return unserialize($variable);
        } else {
            return null;
        }
    }

    function set($file_name, $variable) {
        $file_name = ROOT . DS . 'tmp' . DS . 'cache' . DS . $file_name;
        $handle = fopen($file_name, 'a');
        fwrite($handle, serialize($variable));
        fclose($handle);
    }

}
